DEFINITION MODULE Files;

(*
   Routines for finding information about files.

   Revision history:
     0.00


   Copyright 1987 by:
     Dale W. Thompson, 14500 Dallas Pkwy. #2091, Dallas, TX 75240

     This module and/or its procedures may be freely used by anyone,
     but please acknowledge its use in any copyright notice of a
     publicly distributed program.  Thank you.

     Please forward any comments, problems, or suggestions to me
     at the address given, or to my CompuServe ID 75115,734.
*)

FROM DOSFiles   IMPORT FileLock;
FROM Dates IMPORT DateString;

TYPE
   FileTypes = ( Directory, File );
   FileTypeSet = SET OF FileTypes;
   FileInfo = RECORD
                Name    : ARRAY [0..107] OF CHAR;
                Date    : DateString;
                Comment : ARRAY [0..115] OF CHAR;
                Type    : FileTypes;
                Size    : LONGCARD;               (* File size in bytes *)
              END;
   FileInfoPtr = POINTER TO FileInfo;


PROCEDURE FileExists( VAR name: ARRAY OF CHAR ): BOOLEAN;
(*
    Returns TRUE if file 'name' exists, otherwise returns FALSE
*)


PROCEDURE CopyFile( VAR fileIn, fileOut : ARRAY OF CHAR ): BOOLEAN;
(*
    Returns TRUE if file was copied, else returns FALSE
*)


PROCEDURE ReadDir( VAR Dir : ARRAY OF CHAR;
                   VAR fia : ARRAY OF FileInfo ): CARDINAL;
(*
    Returns number of files in directory
*)


PROCEDURE IsDirectory( VAR file : ARRAY OF CHAR ) : BOOLEAN;
(*
    Returns TRUE of file is a directory, otherwize returns FALSE
*)


PROCEDURE GetFileInfo( VAR file : ARRAY OF CHAR;
                       VAR fia  : FileInfo ): BOOLEAN;
(*
    Returns TRUE if FileInfo filled in, otherwise FALSE
*)


PROCEDURE GetCurrentDir( VAR Path : ARRAY OF CHAR ): BOOLEAN;
(*
   Path is filled with the current directory string.
   Returns TRUE if ok, otherwise FALSE.
*)

PROCEDURE GetSpec(     lock : FileLock;
                   VAR Path : ARRAY OF CHAR ): BOOLEAN;
(*
   Given a file/directory lock, this procedure fills in Path
   with the full file specification. Returns TRUE if ok, otherwise FALSE.
*)


PROCEDURE CurrentDirLock(): FileLock;
(*
   Returns a lock to the current directory.
*)


END (* DEFINITION MODULE *) Files.
